package org.example.controller;

import org.example.domain.Result;
import org.example.domain.UtcItemInfo;
import org.example.dto.PublishContentDto;
import org.example.dto.UpdateContentDto;
import org.example.service.ContentPublishAndAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @FileName ContentPublishAndAuditController
 * @Description 发布与审核
 * @Author coderfun
 * @selfDesc coding in fun
 * @date 2024-11-27
 * ContentPublishAndAudit
 **/
@RestController
@RequestMapping("/content")
public class ContentPublishAndAuditController {

    @Autowired
    private ContentPublishAndAuditService contentPublishAndAuditService;

    @PostMapping("/publish")
    public Result publishContent(@RequestBody PublishContentDto publishContentDto) {
        int a = contentPublishAndAuditService.publishContent(publishContentDto);
        return Result.success(a > 1 ? "success" : "fail");
    }

    @PostMapping("/update")
    public Result updateContent(@RequestBody UtcItemInfo UtcItemInfo) {
        int a = contentPublishAndAuditService.updateContent(UtcItemInfo);
        return Result.success(a > 1 ? "success" : "fail");
    }
}
